<template>
    <div class="content">
        <div class="main">
            <div class="main-box">
                <div class="bjcl">电池报警车辆TOP10</div>
                <div id="bjcl" style="width: 300px; height: 220px" class="echart"></div>
            </div>
        </div>
    </div>
</template>
<script>
import * as echarts from "echarts";
export default {
    name: 'App',
    data() {
        return {}
    },
    mounted: function () {
        this.$nextTick(function () {
            this.getPie()
        })
    },
    methods: {
        getPie() {
            // 绘制图表
            var myChart = echarts.init(document.getElementById('bjcl'))
            // 指定图表的配置项和数据
            var option = {
                title: {
                    x: 'left',              //标题位置
                    textStyle: { //标题内容的样式
                        color: '#FAFAFC',
                        fontStyle: 'normal',
                        fontWeight: 100,
                        fontSize: 16 //主题文字字体大小，默认为18px
                    },
                },
                grid: {
                    left: '8%',
                    right: '8%',
                    top: '18%',
                    containLabel: true
                },
                xAxis: {
                    type: 'category',
                    data: ['NO.1', 'NO.2', 'NO.3', 'NO.4', 'NO.5'],
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#363e83',
                        }
                    },
                    axisLabel: {
                        inside: false,
                        textStyle: {
                            color: '#bac0c0',
                            fontWeight: 'normal',
                            fontSize: '12',
                        },
                        // formatter:function(val){
                        //     return val.split("").join("\n")
                        // },
                    }

                },
                yAxis: {
                    type: 'value',
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#32346c',
                        }
                    },
                    splitLine: {
                        show: true,
                        lineStyle: {
                            color: '#32346c ',
                        }
                    },
                    axisLabel: {
                        textStyle: {
                            color: '#bac0c0',
                            fontWeight: 'normal',
                            fontSize: '12',
                        },
                        formatter: '{value}',
                    }
                },
                series: [
                    {
                        barWidth: 20,
                        data: [27, 22, 20, 16, 12],
                        type: 'bar',
                        showBackground: true,
                        backgroundStyle: {
                            color: 'rgba(180, 180, 180, 0.2)'
                        },
                        itemStyle: {
                            normal: {
                                barBorderRadius: [30],
                                backgroundStyle: {
                                    shadowColor: null,
                                },
                                color: new echarts.graphic.LinearGradient(
                                    0, 0, 0, 1,
                                    [
                                        { offset: 0, color: '#02BDE8' },
                                        { offset: 0.5, color: '#1A9DDD' },
                                        { offset: 1, color: '#3876D0' }
                                    ]
                                ),
                            }
                        }
                    },

                ]
            };

            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option)
        }
    }

}


</script>
<style scoped lang="less">
.content {
    position: relative;
    box-sizing: border-box;
    background-color: rgba(15, 32, 95, 0.7);
}

.main-box {
    position: absolute;
    height: 175px;
    width: calc(100%-4px);
    background-image:
        url("../assets/picture/bj-1.png"),
        url("../assets/picture/bj-2.png"),
        url("../assets/picture/bj-4.png"),
        url("../assets/picture/bj-3.png");
    background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
    background-position: top left, top right, bottom left, bottom right;
    z-index: 1;
    top: 1px;
    left: 1px;
    bottom: 1px;
    right: -2px;
}

.main {
    height: 175px;
    width: 100%;
    border: 1px solid #1723b0;
}

.echart {
    position: absolute;
    top: 0px;
    left: 0px;
}

.bjcl {
    position: absolute;
    top: 5px;
    left: 9px;
    color: #ffffff;
    font-weight: 600;
    font-size: 12px;
}
</style>